package com.panopset.compat;

/**
 * Generic logger.
 * @author Karl Dinwiddie
 *
 */
public final class Logz {

    /**
     * Verbose flag.
     */
    private static boolean v = false;

    /**
     * Turn verbose logging on.
     */
    public static void setVerbose() {
        v = true;
    }

    /**
     * @return True if verbose logging is on.
     */
    public static boolean isVerbose() {
        return v;
    }

    /**
     * Log instance.
     */
    private static final Log LOG = new Log();

    /**
     * Display message regardless whether verbose is true.
     * @param msg Message to display.
     */
    public static void dspmsg(final String msg) {
        LOG.dspmsg(msg);
    }

    /**
     * Display info if verbose is true.
     * @param msg Message to display.
     */
    public static void info(final String msg) {
        if (isVerbose()) {
            LOG.log(msg);
        }
    }

    /**
     *
     * @param msg Message to log regardless whether verbose is true.
     */
    public static void log(final String msg) {
        LOG.log(msg);
    }

    /**
     *
     * @param t Throwable to log regardess whether verbose is true.
     */
    public static void log(final Throwable t) {
        LOG.log(t);
    }

    /**
     * @param logListener Log listener to add.
     */
    public static void addListener(final LogListener logListener) {
        LOG.addListener(logListener);
    }

    /**
     * Prevent instantiation.
     */
    private Logz() { }
}
